//
//  FinishOrderDetailInfoFooterView.m
//  rrqs
//
//  Created by mac book on 2019/5/7.
//

#import "FinishOrderDetailInfoFooterView.h"
@interface FinishOrderDetailInfoFooterView ()



@property(nonatomic,strong) UILabel* beizhuLabel;
@property(nonatomic,strong) UILabel* countLabel;

@property(nonatomic,strong) UILabel* totalLabel;


@property(nonatomic,strong) UILabel* peisongLabel;
@property(nonatomic,strong) UILabel* youhuiLabel;
@property(nonatomic,strong) UILabel* peisongValueLabel;
@property(nonatomic,strong) UILabel* youhuiValueLabel;


@property(nonatomic,strong) UILabel* shifuLabel;



@end

@implementation FinishOrderDetailInfoFooterView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if(self){
        [self layoutUI];
    }
    return self;
}

#pragma mark =====================================================  user interface layout
-(void)layoutUI{
    
    
    [self addSubview:self.beizhuLabel];
    [self addSubview:self.countLabel];
    [self addSubview:self.totalLabel];
    
    
    [self addSubview:self.peisongLabel];
    [self addSubview:self.youhuiLabel];
    [self addSubview:self.peisongValueLabel];
    [self addSubview:self.youhuiValueLabel];
    [self addSubview:self.shifuLabel];


    
    [self.beizhuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self);
        make.left.equalTo(self).offset(15);
        make.height.mas_equalTo(30);
        make.right.equalTo(self).offset(-15);

    }];
    
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.beizhuLabel.mas_bottom).offset(5);
        make.left.right.equalTo(self.beizhuLabel);
        make.height.mas_equalTo(20);

    }];
    
    
    [self.totalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.countLabel.mas_bottom);
        make.left.right.height.equalTo(self.countLabel);
        
    }];
    
    
    
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.totalLabel.mas_bottom).offset(5);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.height.mas_equalTo(0.8);
        
    }];
    
    
    
    [self.peisongLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(line).offset(10);
        make.left.equalTo(self).offset(15);
        make.width.equalTo(self).multipliedBy(0.5);
        make.height.mas_equalTo(20);
        
    }];
    
    [self.peisongValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.peisongLabel);
        make.left.equalTo(self.peisongLabel.mas_right);
        make.right.equalTo(self).offset(-15);
        make.height.equalTo(self.peisongLabel);
        
    }];
    
    
    
    [self.youhuiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.peisongLabel.mas_bottom);
        make.left.right.equalTo(self.peisongLabel);
        make.height.equalTo(self.peisongLabel);
        
    }];
    
    
    [self.youhuiValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.youhuiLabel);
        make.left.equalTo(self.youhuiLabel.mas_right);
        make.right.equalTo(self.peisongValueLabel);
        make.height.equalTo(self.youhuiLabel);
        
    }];
    
    UIView *line1 = [[UIView alloc] init];
    line1.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self addSubview:line1];
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.youhuiLabel.mas_bottom).offset(5);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.height.mas_equalTo(0.8);
        
    }];
    
    
    [self.shifuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(line1).offset(0);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.bottom.equalTo(self);

    }];
    
    
    
    
    self.peisongLabel.text = @"配送费";
    self.youhuiLabel.text = @"优惠";

    
}

-(void)setEntity:(MOrder *)entity{
    
    
    _entity = entity;
    
    self.beizhuLabel.text = [NSString stringWithFormat:@"备注:%@",entity.postscript];
    
    self.countLabel.text = [NSString stringWithFormat:@"%ld件商品",entity.goods_info.count];
    self.totalLabel.text = [NSString stringWithFormat:@"合计:%@",entity.heji];

    self.peisongValueLabel.text = [NSString stringWithFormat:@"￥%@",entity.peisong];
    self.youhuiValueLabel.text = [NSString stringWithFormat:@"-￥%@",entity.youhui];

    self.shifuLabel.text = [NSString stringWithFormat:@"实付￥%@",entity.shifu_price];

    
}


-(UILabel *)beizhuLabel{
    if(!_beizhuLabel){
        _beizhuLabel = [[UILabel alloc]init];
        _beizhuLabel.textColor =kMyColor(130, 130, 130);
        _beizhuLabel.font = kFontNameSize(12);
    }
    return _beizhuLabel;
}

-(UILabel *)countLabel{
    if(!_countLabel){
        _countLabel = [[UILabel alloc]init];
        _countLabel.textColor =kMyColor(130, 130, 130);
        _countLabel.font = kFontNameSize(12);
        _countLabel.textAlignment = NSTextAlignmentRight;
    }
    return _countLabel;
}


-(UILabel *)totalLabel{
    if(!_totalLabel){
        _totalLabel = [[UILabel alloc]init];
        _totalLabel.textColor =kMyColor(130, 130, 130);
        _totalLabel.font = kFontNameSize(12);
        _totalLabel.textAlignment = NSTextAlignmentRight;
    }
    return _totalLabel;
}

-(UILabel *)peisongLabel{
    if(!_peisongLabel){
        _peisongLabel = [[UILabel alloc]init];
        _peisongLabel.textColor =kMyColor(130, 130, 130);
        _peisongLabel.font = kFontNameSize(12);
    }
    return _peisongLabel;
}


-(UILabel *)youhuiLabel{
    if(!_youhuiLabel){
        _youhuiLabel = [[UILabel alloc]init];
        _youhuiLabel.textColor = [UIColor redColor];
        _youhuiLabel.font = kFontNameSize(12);
    }
    return _youhuiLabel;
}

-(UILabel *)peisongValueLabel{
    if(!_peisongValueLabel){
        _peisongValueLabel = [[UILabel alloc]init];
        _peisongValueLabel.textColor =kMyColor(130, 130, 130);
        _peisongValueLabel.font = kFontNameSize(12);
        _peisongValueLabel.textAlignment = NSTextAlignmentRight;
    }
    return _peisongValueLabel;
}


-(UILabel *)youhuiValueLabel{
    if(!_youhuiValueLabel){
        _youhuiValueLabel = [[UILabel alloc]init];
        _youhuiValueLabel.textColor =[UIColor redColor];;
        _youhuiValueLabel.font = kFontNameSize(12);
        _youhuiValueLabel.textAlignment = NSTextAlignmentRight;
    }
    return _youhuiValueLabel;
}

-(UILabel *)shifuLabel{
    if(!_shifuLabel){
        _shifuLabel = [[UILabel alloc]init];
        _shifuLabel.textColor =[UIColor redColor];;
        _shifuLabel.font = kFontNameSize(14);
        _shifuLabel.textAlignment = NSTextAlignmentRight;
    }
    return _shifuLabel;
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
